<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('请假申请列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "form";
    var currentUser = [[${currentUser}]];
    $(function() {
        var options = {
            url: prefix + "/list",
            sortName: "id",
            sortOrder: "desc",
            modalName: "表单定义",
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : '主键ID',
                    visible: true
                },
                {
                    field : 'formName',
                    title : '表单名称',
                    align : 'center',
                },
                {
                    field : 'processDef',
                    title : '关联流程'
                },
                {
                    title : '操作',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push("<a onclick=\'designForm("+row.id+")\'>设计表单</a>") ;
                        if(row.processDef){
                            actions.push("<a onclick=\'addFormData("+row.id+")\'>填写表单</a>") ;
                        }else{
                            actions.push("<a onclick=\'linkProcess("+row.id+")\'>关联流程</a>") ;
                        }
                        return actions;
                    }
                },
                ]
        };
        $.table.init(options);
    });

    function designForm(id) {
        $.modal.openTab("编辑表单设计","/form/design/"+id);
    }

    function addFormData(id) {
        $.modal.open("填写表单","/form/show?id="+id,800,500,function(index,layero){
            var iframeWin = layero.find('iframe')[0];
            iframeWin.contentWindow.submitHandler(id,index, layero);
            $.modal.closeAll();
        });
    }
    function linkProcess(id) {
        $.modal.open("关联流程","/process/linkProcess?formId="+id,800,500);
    }
</script>
</body>
</html>
